<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.List,java.util.Map,com.hz.framework.dao.CommonDao"%>
<%@ include file="../common/commonJS.jsp" %>
<%@ include file="../common/commonLabel.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>已完工订单信息列表</title>
</head>
<script type="text/javascript">
function finishOrder(oid){
	window.location.href="<%=request.getContextPath()%>/balanceOrder.action?oid="+oid;
}
function doInsOrder(){
	document.forms[0].action = "<%=request.getContextPath() %>/endgather.action?operate=inspage&parentlink=6&sonlink=17";
	document.forms[0].submit();
}
//导出发货单
function doDeliverprint(){
	var bow = false;
	var sups = document.all["supp"];
	if(sups.length){
		for (var i=0; i<sups.length; i++) {
		    if (sups[i].checked) {
				bow = true;
				break;
		    }
		}
	}else{
		if (sups.checked) {
			bow = true;
		}
	}
	if(bow){
		var oldaction = document.forms[0].action;
		document.forms[0].action = "<%=request.getContextPath() %>/docs/ys_clientorder/finish_order_print.jsp";
		document.forms[0].submit();
		document.forms[0].action = oldaction;
	}else{
		_alert("请至少选择一条数据进行发货。");
	}
}
//标记状态
function doSign(obj,oid,sign){
	if(oid!=""){
		var td = obj.parentNode;
		comdwr.sign_Order(oid,sign,function(bow){
			if(bow){
				if(sign=="start"){
					td.firstChild.innerHTML = "重新发货&nbsp;";
					td.childNodes[1].style.display = "none";
					td.childNodes[2].style.display = "";
					td.childNodes[3].style.display = "";
				}else{
					td.firstChild.innerHTML = "已发货&nbsp;";
					td.childNodes[1].style.display = "";
					td.childNodes[2].style.display = "none";
					td.childNodes[3].style.display = "none";
				}
			}
		});
	}
}
//选择订单进行发货
function setpurc(obj){
	if(obj.checked){
		doChecktrue("supp");
	}else{
		doCheckfalse("supp");
	}
}
//追踪信息
function doTrace(obj,oid){
	doQueryMess("<%=request.getContextPath() %>/traceinfo.action?operate=inspage&oid="+oid,"","500","300");
}
</script>
<body>
<form action="<%=request.getContextPath() %>/finishOrderList.action" method="post" >
<table width="82%" border="0" cellpadding="0" cellspacing="0" >
  <tr>
     <td>
     <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" class="MainBody">
      <tr>
        <td width="760" class="MainBody_title"><hello:forValue type="title" /></td>
        <td></td>
      </tr>
      <tr>
        <td valign="top" colspan="2"><input name="orderids" type="hidden" value=""/>
        <table border="0" cellspacing="0" cellpadding="0" style="margin: 5px 0 10px 20px;width:90%">
			<tr height="35">
				<td align="right"></td>
				<td align="right" ><input type="button" class="btn" value="订单结算" onclick="doInsOrder()"/>
				<c:if test="${carryType=='发货'}">
				&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="btn" value="发货单导出" onclick="doDeliverprint()" style="width: 80px"/>
				</c:if></td>
			</tr>
			<tr >
				<td colspan="2" class="box01">
				<SPAN>交货日期：<input type="text" name="begin" value="${begin}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:false})" class="Wdate" maxlength="30">
				&nbsp;&nbsp;至&nbsp;&nbsp;<input type="text" name="end" value="${end}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:false})" class="Wdate" maxlength="30"></SPAN>
				<SPAN>发货状态：<select name="deliver" style="width: 65" onchange="document.forms[0].submit();">
					<option value="start" <c:if test="${deliver=='start'}">selected</c:if>>未发货</option>
					<option value="finish" <c:if test="${deliver=='finish'}">selected</c:if>>已发货</option>
					<option value="all" <c:if test="${deliver=='all'}">selected</c:if>>全部</option>
					</select></SPAN>
				<SPAN>提货方式：<select name="carryType" style="width: 65" onchange="document.forms[0].submit();">
					</select></SPAN>
				</td>
			</tr>
		</table>
       <!--<input name="toIns" value="添加" type="button" class="btn" onclick="location.href='order_ins.jsp'"/>-->
        <table border="0" cellpadding="0" cellspacing="0"  class="MainBody_table">
			<tr>
				<th nowrap="nowrap" width="5%"><INPUT type="checkbox" onclick="setpurc(this)" ></th>
				<th nowrap="nowrap">订单编号</th>
				<th nowrap="nowrap">订单名称</th>
				<th nowrap="nowrap">客户名称</th>
				<th nowrap="nowrap" width="9%">下单日期</th>
				<th nowrap="nowrap" width="9%">交货日期</th>
				<th nowrap="nowrap" width="9%">结算日期</th>
				<th nowrap="nowrap" width="10%">联系电话</th>
				<th nowrap="nowrap" width="7%">欠款</th>
				<th nowrap="nowrap" width="15%">操作</th>
			</tr>
             	<% 
             	String fin,sta="";
             	  if(request.getAttribute("list")!=null&&!((List)request.getAttribute("list")).isEmpty()){
             		List list = (List)request.getAttribute("list");
             		for(int i=0;i<list.size();i++){
             			Map c = (Map)list.get(i);
             	 %>
			<tr>
				<td align="center" nowrap="nowrap"><INPUT type="checkbox" name="supp" value="<%=c.get("orderId") %>"></td>
				<td align="center" nowrap="nowrap"><a href="<%=request.getContextPath()%>/orderSel.action?cid=<%=c.get("cId") %>&oid=<%=c.get("oid") %>" title="订单详细信息"><%=c.get("orderId") %></a></td>
				<td align="center" nowrap="nowrap"><a href="<%=request.getContextPath()%>/orderSel.action?cid=<%=c.get("cId") %>&oid=<%=c.get("oid") %>" title="订单详细信息"><%=c.get("name") %></a></td>
				<td align="center" nowrap="nowrap"><%=CommonDao.isnull(c.get("otherClient")).equals("")?CommonDao.isnull(c.get("clientName")):c.get("otherClient") %></td>
				<td align="center" nowrap="nowrap"><%=c.get("orderTime") %></td>
				<td align="center" nowrap="nowrap"><%=c.get("finishTime") %></td>
				<td align="center" nowrap="nowrap"><%=c.get("balanceTime") %></td>
				<td align="center" nowrap="nowrap"><%=CommonDao.isnull(c.get("otherTel")).equals("")?CommonDao.isnull(c.get("phone")):c.get("otherTel") %></td>
				<td align="center" nowrap="nowrap"><%=CommonDao.isnull(c.get("debtcash")) %></td>
				<td align="center" nowrap="nowrap">
				<span>
				<%if("load".equals(c.get("deliverflag"))){ fin="";sta="none";%>
					发货中&nbsp;
				<% }else if("finish".equals(c.get("deliverflag"))){ fin="none";sta="";%>
					已发货&nbsp;
				<% }else if("start".equals(c.get("deliverflag"))){ fin="";sta="none";%>
					重新发货&nbsp;
				<% }else{ fin="none";sta="none";%>
					未发货&nbsp;
				<% } %>
				</span><span class='RoleSpan' onclick="doSign(this,'<%=c.get("orderId") %>','start')" title='标记该订单重新发货' style='color: red;display: <%=sta %>' onmouseout="doMsOut('red')" onmouseover='doMsOver()'>标记重发
				</span><span class='RoleSpan' onclick="doSign(this,'<%=c.get("orderId") %>','finish')" title='标记该订单已发货' style='color: green;display: <%=fin %>' onmouseout="doMsOut('green')" onmouseover='doMsOver()'>标记已发
				</span><span class='RoleSpan' onclick="doTrace(this,'<%=c.get("orderId") %>')" title='追踪记录信息' style='color: green;display: <%=sta %>' onmouseout="doMsOut('green')" onmouseover='doMsOver()'>追踪记录</span>
				</td> 
			</tr>
			<%		}//for end
             	}else{%>
		<tr>
			<td align="center" colspan="10">暂时没有您可以浏览的数据</td>
		</tr>
			<%  } %>
          </table>
          <table border="0" cellpadding="0" cellspacing="0" class="MainBody_fun">
            <tr>
              <td>
               <hello:AllPage />
			  </td>
            </tr>
          </table>
          </td>
      </tr>
    </table></td>
  </tr>
</table>
</form>
<script type="text/javascript">
doSelectInfo(document.all["carryType"],'carryType','${carryType}',false);
</script>
</body>
</html>